package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.supervision.dto.create.JzdxEmploymentCreateDTO;
import com.engine4cloud.tdf.supervision.dto.update.JzdxEmploymentUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.JzdxEmploymentEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface JzdxEmploymentConvert {
    JzdxEmploymentConvert INSTANCE = Mappers.getMapper(JzdxEmploymentConvert.class);

    @Mapping(target = "id", ignore = true)
    JzdxEmploymentEntity create(JzdxEmploymentCreateDTO s);

    JzdxEmploymentEntity updateTo(JzdxEmploymentUpdateDTO s);

    JzdxEmploymentCreateDTO updateCreate(JzdxEmploymentUpdateDTO s);

    default JzdxEmploymentEntity createList(JzdxEmploymentCreateDTO s) {
        JzdxEmploymentEntity entity = create(s);
        //设置捕前职业
        entity.setPqzy(s.getPreProfessionList().get(s.getPreProfessionList().size() - 1));
        return entity;
    }

    default JzdxEmploymentEntity update(JzdxEmploymentUpdateDTO s) {
        JzdxEmploymentEntity entity = updateTo(s);
        //设置捕前职业
        entity.setPqzy(s.getPreProfessionList().get(s.getPreProfessionList().size() - 1));
        return entity;
    }

}
